package base.day20;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class MyTreeSet4 {
    public static void main(String[] args) {
        TreeSet<Teacher> teas=new TreeSet<>(new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int result=o1.getAge()-o2.getAge();
                result=result==0?o1.getName().compareTo(o2.getName()):result;
                return result;
            }
        });
        Teacher tea1=new Teacher("zhangsan",23);
        Teacher tea2=new Teacher("lisi",24);
        Teacher tea3=new Teacher("wangwu",23);
        teas.add(tea1);
        teas.add(tea2);
        teas.add(tea3);
        System.out.println(teas);
    }
}
